package cn.edu.scujcc;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DynamicService {
	@Autowired
	private DynamicRepositroy repo;
	
	public List<Dynamic> getAllDynamic(){
		List<Dynamic>result = null;
		result = repo.findAll();
		return result;
	}
	public Dynamic getDynamic(String id) {
		Dynamic result = null;
		Optional<Dynamic> op = repo.findById(id);
		if (op.isPresent()) {
			result = op.get();
			}
		return result;
		}
	
	public Dynamic createComment(String id) {
		Dynamic result = null;
		Optional<Dynamic> op = repo.findById(id);
		if (op.isPresent()) {
			result = op.get();
			}
		return result;
		}
}